package org.ruanjj.stringreverse;

public class Solution2 {
    public String reverseMessage(String message){
        StringBuilder res = new StringBuilder();
        String[] splitMessage = message.trim().split(" ");
        if(splitMessage.length > 0){
            for(int i = splitMessage.length-1; i >= 0; i--){
                if(splitMessage[i].equals("")) continue;
                res.append(splitMessage[i]).append(" ");
            }
        }
        return res.toString().trim();
    }
}
